package com.feicheng.controller.wx;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.feicheng.common.exception.SystemException;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.persistence.entity.Product;
import com.feicheng.service.IFProductService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cailongyang
 * @since 2022-01-10
 */
@RestController("/wx/product")
@RequestMapping("/wx/product")
public class ProductController {

	@Autowired 
	IFProductService productService;
			//产品分页查询
			@GetMapping("/page")
			public ResultInfo getProductsByPage(Integer categoryId) {
				
				if (null == categoryId) {
					throw new SystemException("分类主键缺失");
				}
				
				return productService.getProductsBycategoryId(categoryId);
			}
			
			//产品详细查询
			@GetMapping("/info")
			public ResultInfo getProductinfo(Integer productId) {
				if (null == productId) {
					throw new SystemException("产品主键缺失");
				}
				return productService.getProductDetail(productId);
			}
			
}
